package cn.exrick.xboot.modules.assessment.dao;

import cn.exrick.xboot.base.XbootBaseDao;
import cn.exrick.xboot.modules.assessment.entity.HkAssessmentIndex;

import cn.exrick.xboot.modules.assessment.vo.HkAssessmentInfoVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * 考核指标数据处理层
 *
 * @author yck
 */
public interface HkAssessmentIndexDao extends XbootBaseDao<HkAssessmentIndex, String> {
    HkAssessmentIndex findByIndexName(String indexName);

    @Query(value = "SELECT new cn.exrick.xboot.modules.assessment.vo.HkAssessmentInfoVo(frs.id,ai.indexName,ai.indexDescribe,ai.indexClassifyName,ai.hontPostName,ai.indexScore)" +
            "FROM HkAssessmentIndex ai " +
            "INNER JOIN HkFormRelationShip frs ON frs.itemId = ai.id " +
            "WHERE frs.formId = :formEntityId " +
            "and ai.indexType = :indexType")
    List<HkAssessmentInfoVo> findByFormEntityIdAndIndexType(@Param("formEntityId") String formEntityId, @Param("indexType")Integer indexType);


}